<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/js/uploadify/jquery.uploadify.min.js" ></script>
<link rel="stylesheet" charset="utf-8" type="text/css" href="__PUBLIC__/admin/js/uploadify/uploadify.css"> 
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/js/upload.js" ></script>
<!-- 配置文件 -->
<script type="text/javascript" src="__PUBLIC__/admin/js/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__PUBLIC__/admin/js/ueditor/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
	var ue = UE.getEditor('edit');
</script>

<style>
.bg{ background: none; border: none;}
.uploadify-button-text{ display: inline-flex; }
.uploadify-button-text button{ margin: -10px; }
.upviewer img{ height:90px; width: 120px; }
.upviewer ul{ margin:0px; padding:0px; }
.upviewer li{ margin:0px; padding:0px; position: relative; display:inline-block; width:120px; height:90px; background-position: center; background-size: contain; background-repeat: no-repeat; float: left; margin-right:10px; border:1px #ccc solid; background-color:#f0f0f0;}
.upviewer li a{ display:inline-block; position: absolute; bottom:0px; left:0px; text-align:center; width:100%; background-color:rgba(0,0,0,0.3); color:red; cursor: pointer; }
.upviewer li:hover a{ background-color:rgba(0,0,0,0.8); }
</style>
<div class="container" style="padding-top: 50px;">
	<div class="row clearfix">
		<div class="col-md-12 column">
			<form class="form-horizontal" role="form" method="post" action="{:U('')}" id="post_form">
				<eq name="is_dealer" value="1">
					<input type="hidden" name="nearby_shop_id" value="{$admin_user['nearby_shop_id']}">
				<else/>
					<div class="form-group">
						<label for="nearby_shop_id" class="col-sm-2 control-label">经销商:</label>
						<div class="col-sm-2">
							<div class="control-group">
								<select name="nearby_shop_id" id="nearby_shop_id" class="form-control"> 
									<option value="0">请选择经销商</option>
									<volist name="nearby_shop" id="vo">
										<option value="{$key}">{$vo}</option>
									</volist>
								</select>
							</div>
						</div>
					</div>
				</eq>
				<div class="form-group" style="display: none;">
					<label for="brand_id" class="col-sm-2 control-label">品牌:</label>
					<div class="col-sm-2">
						<div class="control-group">
							<select name="brand_id" id="brand_id" class="form-control"> 
								<option value="0">请选择品牌</option>
								<volist name="brand_arr" id="vo">
									<option value="{$key}">{$vo}</option>
								</volist>
							</select>
						</div>
					</div>
				</div>
                <div class="form-group">
                     <label for="ad_id" class="col-sm-2 control-label">关联广告:</label>
                    <div class="col-sm-4">
                        <select class="form-control" name="ad_id" id="ad_id">
                            <option value="0">不关联</option>
                            <volist name="advertising" id="data" >
                                <option value="{$data.id}">{$data.title}</option>
                            </volist>
                        </select>
                    </div>
                </div>
				<div class="form-group">
					<label for="goods_name" class="col-sm-2 control-label">商品名:</label>
					<div class="col-sm-2">
						<input type="text" class="form-control" id="goods_name" name="goods_name" />
					</div>
				</div>
                <div class="form-group">
                    <label for="price" class="col-sm-2 control-label">价格:</label>
                    <div class="col-sm-2">
                        <input type="number" class="form-control" id="price" name="price" />
                    </div>
                </div>
				
				
				<div class="form-group">
					<label for="inputPassword3" class="col-sm-2 control-label">商品列表图片(240x240):</label>
					<div class="col-sm-10 js_upload_img">
						<input type="file" class="form-control" id="picture" placeholder="照片"><br />    	  
				    	<div name="picture" class="upviewer" ><ul></ul></div>
					</div>
				</div>

                <div class="form-group">
                    <label for="inputPassword3" class="col-sm-2 control-label">支付宝二维码:</label>
                    <div class="col-sm-10 js_upload_img">
                        <input type="file" class="form-control" id="alipay_qr" placeholder="支付宝二维码"><br />          
                        <div name="alipay_qr" class="upviewer" ><ul></ul></div>
                    </div>
                </div>

                <div class="form-group">
                    <label for="inputPassword3" class="col-sm-2 control-label">微信支付二维码:</label>
                    <div class="col-sm-10 js_upload_img">
                        <input type="file" class="form-control" id="wechat_pay_qr" placeholder="微信支付二维码"><br />          
                        <div name="wechat_pay_qr" class="upviewer" ><ul></ul></div>
                    </div>
                </div>
				
				<div class="form-group">
					 <label for="content" class="col-sm-2 control-label">商图详情:</label>
					<div class="col-sm-10" >
					<textarea id="edit" name="content" id="content" type="text/plain"></textarea>
					</div>
				</div>
				
                <div class="form-group">
                    <label for="ds" class="col-sm-2 control-label">排序:<span style="color: red;">*</span></label>
                    <div class="col-sm-5" >
                        <input type="number" class="form-control" name="sort" id="sort" value="100" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">状态:</label>
                    <div class="col-sm-10">
                        <label for="is_on_sale1" class="control-label">
                            <input type="radio" id="is_on_sale1" name="is_on_sale" value="0">下架
                        </label>
                        <label for="is_on_sale2" class="control-label">
                            <input type="radio" id="is_on_sale2" name="is_on_sale" value="1"  checked>上架
                        </label>
                    </div>
                </div>
				<div class="form-group">
					<div class="col-sm-offset-2 col-sm-10">
						 <button type="button" class="btn btn-primary button">提交</button>
					</div>
				</div>
			</form>
		</div>
</div>
<script>
$(function(){
	 $(".button").click(function(){
		var $form = $("#post_form");
        var $data = {};
        var $form_data = $form.serializeArray();
        $.each($form_data, function(k, v){
            $data[v['name']] = v['value'];
        })
        
        $.post($form.attr('action'), $data, function(obj){
            alert(obj.m);
            if(obj.s){
                if(typeof(obj.url)!= "undefined" && obj.url){
                    location.href = obj.url;
                }
            }
        })
        return false;
	 })
});
</script>
